
<!--- <cfinvoke component="#request.pathToGateways#.StudentGateway" method="query" returnvariable="students">
	<cfif IsDefined("organizationID")>
		<cfinvokeargument name="Organization_ID" value="#organizationID#" />
	</cfif>
	<cfif IsDefined("userID")>
		<cfinvokeargument name="userIDs" value="#userID#" />
	</cfif>
</cfinvoke> --->

<cfif students.RecordCount gt 0>
	<table class="table table-striped table-bordered">
		<thead>
			<tr>
				<th>ID</th>
				<th>Site</th>
				
				
				
				
				
				<th>Date/Time</th>
				<th>Organizer</th>
				<th>Site Contact</th>
				<th>Students</th>
				<th>Status</th>
			</tr>
		</thead>
		<tbody>
			<cfoutput query="students">
				<tr>
					<td>#Student_ID#</td>
					<td>#Site#</td>
					<td>#Origin#</td>
					<td>#First_Name#</td>
					<td>#Last_Name#</td>
					<td>#Address#</td>
					<td>#City#</td>
					<td>#Phone1#</td>
					<td>#Phone2#</td>
					<td>#DateFormat(DOB, "m/d/yyyy")#</td>
				</tr>
				<!--- <tr>
						<td><a href="#script_name#?view=editStudent&workshopID=#Student_ID#">#Student_ID#</a></td>
						<td>#Site#</td>
						<td>#DateFormat(Student_Date, "m/d/yyyy")# #TimeFormat(Start_Time, "h:mmtt")#-#TimeFormat(End_Time, "h:mmtt")#</td>
						<td>
							<cfif Organizer_Approved>
								#Organizer_Full_Name#
							<cfelseif Organizer_Deleted>
								<font color="red">#Organizer_Full_Name#</font>
							<cfelseif Organizer_Archived>
								<font color="silver">#Organizer_Full_Name#</font>
							<cfelseif NOT Organizer_Approved>
								<font color="orange">#Organizer_Full_Name#</font>
							</cfif>
						</td>
						<td>
							<cfif Manager_Approved>
								#Manager_Full_Name#
							<cfelseif Manager_Deleted>
								<font color="red">#Manager_Full_Name#</font>
							<cfelseif Manager_Archived>
								<font color="silver">#Manager_Full_Name#</font>
							<cfelseif NOT Manager_Approved>
								<font color="orange">#Manager_Full_Name#</font>
							</cfif>
						</td>
						<td>
							<cfif Student_Date lt Now()>
								#Student_Count#
							</cfif>
						</td>
						<td>
							<cfif Approved>
								Approved
							<cfelseif Deleted>
								<font color="red">Deleted</font>
							<cfelseif NOT Approved>
								<font color="orange">Not Approved</font>
							</cfif>
						</td>
					</tr> --->
			</cfoutput>
		</tbody>
	</table>
<cfelse>
	<div class="alert alert-info notFound">No stuents</div>
</cfif>

<!--- <!--- Role params --->
<cfparam name="organizationID" type="integer" default="0">
<cfparam name="regionID" type="integer" default="0">
<!--- Sorting params --->
<cfparam name="orderBy" type="string" default="#client.studentsOrderBy#">
<cfparam name="orderDir" type="string" default="#client.studentsOrderDir#">
<!--- Filter params --->
<cfparam name="filterOrganizationIDs" type="string" default="#client.studentsOrganizationIDs#">
<cfparam name="filterRegionIDs" type="string" default="#client.studentsRegionIDs#">
<cfparam name="filterSiteIDs" type="string" default="#client.studentsSiteIDs#">
<cfparam name="filterPBS" type="string" default="#client.studentsPBS#">
<cfparam name="filterSearchCriteria" type="string" default="#client.studentsSearchCriteria#">
<cfparam name="filterPeriod" type="string" default="#client.studentsPeriod#">
<cfparam name="filterYear" type="string" default="#client.studentsYear#">
<!--- Checkboxes --->
<cfparam name="studentIDs" type="string" default="0">

<cfset students = application.studentGateway.getAllAsQuery("*", organizationID, regionID, orderBy, orderDir, filterOrganizationIDs, filterRegionIDs, filterPBS, filterSiteIDs, filterSearchCriteria, 0, 'All', 0, false, filterPeriod, filterYear)>

<cfoutput>

	<cfform name="studentsForm" id="studentsForm" action="#script_name#" method="post">
		<cfinput type="hidden" name="view" value="#view#">

		<div class="buttonBar">
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td>
						<cfif students.RecordCount gt 0>
							<cfif IsUserInRole("Super User")>
								<a href="/applications/admin/methods/export.cfm?view=#view#&exportFormat=full&pbs=#filterPBS#&regionIDs=0&searchCriteria=#filterSearchCriteria#&period=#filterPeriod#&year=#filterYear#" target="_blank" class="formLink">Export All Regions</a>
								<a href="" onclick="emailSelected(); return false;" class="formLink">E-mail selected</a>
							<cfelseif IsUserInRole("Regional Admin")>
								<a href="/applications/admin/methods/export.cfm?view=#view#&exportFormat=full&pbs=#filterPBS#&regionIDs=#authUser.getRegion_IDs()#&searchCriteria=#filterSearchCriteria#&period=#filterPeriod#&year=#filterYear#" target="_blank" class="formLink">Export</a>
							</cfif>
						</cfif>
					</td>
					<td align="right" nowrap="nowrap">
						<strong>Count:</strong> #students.RecordCount#
					</td>
				</tr>
			</table>
		</div>

		<!--- filter --->
		<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
			<script type="text/javascript" language="javascript">
			<!--
				toggleVisibility = function(objId) {
					var obj = document.getElementById(objId);
					if (obj.style.visibility == "visible") {
						obj.style.visibility = "hidden";
						obj.style.display = "none";
					} else {
						obj.style.visibility = "visible";
						obj.style.display = "block";
					}
				}

				updateFilterLink = function() {
					if (document.getElementById("filterSelections").style.visibility == "visible") {
						document.getElementById("filterLink").innerHTML = '#minusImage#&nbsp;Hide Filter';
					} else {
						document.getElementById("filterLink").innerHTML = '#plusImage#&nbsp;Show Filter';
					}
				}

				updateIDsSelect = function(selectObj) {
					if (selectObj.selectedIndex == 0) {
						selectObj.selectedIndex = 0;
					}
				}

				updateTimePeriod = function(radioObj) {
					if ($(radioObj).val() == "Year") {
						$("##filterYear").show();
					} else {
						$("##filterYear").hide();
					}
					$("##filterYear").attr("selectedIndex", 0);
				}

			// -->
			</script>

			<cfset organizations = application.organizationGateway.getAllAsQuery("Organization_ID,Organization", organizationID, regionID, "Organization")>
			<cfset regions = application.countyGateway.getRegions()>
			<cfset sites = application.siteGateway.getActiveSites()>

			<table class="filter" width="100%">
				<tr>
					<td class="filterHeader"><a id="filterLink"href="" onclick="toggleVisibility('filterSelections'); toggleVisibility('filterButtons'); updateFilterLink(); return false;" style="width: 100px; display: inline-block;">#plusImage#&nbsp;Show Filter</a><cfif filterOrganizationIDs neq 0 or filterRegionIDs neq 1 or filterSiteIDs neq 0 or Len(Trim(filterSearchCriteria)) or filterPBS neq application.DEFAULT_PBS gt 0 or filterPeriod neq "Year" or filterYear neq request.programYears.current.workshop>List is filtered</cfif></td>
				</tr>
				<tr id="filterSelections" style="visibility: hidden; display: none;">
					<td>

						<table>
							<tr>
								<cfif IsUserInRole("Super User")>
									<td>
										<fieldset>
											<legend>Region</legend>
											<cfselect name="filterRegionIDs" size="1" multiple="false" required="yes" message="Region filter is required" onChange="updateIDsSelect(this);" style="width: 80px;">
												<cfloop query="regions">
													<option value="#Region_ID#"<cfif ListFind(filterRegionIDs, Region_ID)> selected</cfif>>#Region_ID#</option>
												</cfloop>
											</cfselect>
										</fieldset>
									</td>
									<td>
										<fieldset>
											<legend>PBS</legend>
											<input type="radio" id="pbs1" name="filterPBS" value="All"<cfif filterPBS eq "All"> checked="true"</cfif>><label for="pbs1">&nbsp;All</label><br>
											<input type="radio" id="pbs2" name="filterPBS" value="Yes"<cfif filterPBS eq "Yes"> checked="true"</cfif>><label for="pbs2">&nbsp;PBS</label><br>
											<input type="radio" id="pbs3" name="filterPBS" value="No"<cfif filterPBS eq "No"> checked="true"</cfif>><label for="pbs3">&nbsp;Non-PBS</label>
										</fieldset>
									</td>
								</cfif>
								<td>
									<fieldset>
										<legend>Keywords</legend>
										<cfinput type="text" name="filterSearchCriteria" value="#filterSearchCriteria#" size="20">
									</fieldset>
								</td>
								<td>
									<fieldset>
										<legend>Program Year</legend>
										<input type="radio" id="Period1" name="filterPeriod" value="All" onclick="updateTimePeriod(this);"<cfif filterPeriod eq "All"> checked="true"</cfif>><label for="Period1">&nbsp;All Program Years</label><br>
										<input type="radio" id="Period2" name="filterPeriod" value="Year" onclick="updateTimePeriod(this);"<cfif filterPeriod eq "Year"> checked="true"</cfif>><label for="Period2">&nbsp;Program Year</label>
										<select name="filterYear" id="filterYear" size="1"<cfif filterPeriod neq "Year"> style="display: none;"</cfif>>
											<cfloop list="#listSort(structKeyList(request.programYears.workshop), "text")#" index="i">
												<option value="#i#"<cfif filterYear eq i> selected</cfif>>#i#</option>
											</cfloop>
										</select>
									</fieldset>
								</td>
								<td width="100%"></td>
							</tr>
						</table>

					</td>
				</tr>
				<tr id="filterButtons" style="visibility: hidden; display: none;">
					<td>
						<div style="margin-bottom: 4px;">
							<cfinput type="submit" name="applyFilterButton" id="applyFilterButton" value="Apply Filter" class="formButton2">
							<cfif filterOrganizationIDs neq 0 or filterRegionIDs neq 1 or filterSiteIDs neq 0 or Len(Trim(filterSearchCriteria)) or filterPBS neq application.DEFAULT_PBS gt 0 or filterPeriod neq "Year" or filterYear neq request.programYears.current.workshop>
								<a href="#script_name#?view=#view#&filterOrganizationIDs=0&filterRegionIDs=1&&filterSiteIDs=0&filterPBS=#application.DEFAULT_PBS#&filterPeriod=Year&filterYear=#request.programYears.current.workshop#" class="formLink2">Clear filter</a>
							</cfif>
						</div>
					</td>
				</tr>
			</table>
		</cfif>

		<cfif students.RecordCount gt 0>

			<!--- checkbox functions --->
			<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
				<script type="text/javascript" language="javascript">
				<!--
					toggleSelectAll = function(f) {
						var c = f.selectAllCheckbox;
						for (var i=0; i<f.studentIDs.length; i++) {
							if (c.checked) {
								f.studentIDs[i].checked = true;
							} else {
								f.studentIDs[i].checked = false;
							}
						}
					}

					updateSelectAll = function(chk) {
						if (!chk) {
							document.getElementById("selectAllCheckbox").checked = false;
						}
					}

					emailSelected = function() {
						var f = document.getElementById("studentsForm");
						var studentIDs = new Array();
						for (var i=0; i<f.studentIDs.length; i++) {
							if (f.studentIDs[i].checked) {
								studentIDs[studentIDs.length] = f.studentIDs[i].value;
							}
						}
						if (studentIDs.length == 0) {
							alert("Select at least one student");
						} else {
							eSF = document.getElementById("emailSelectedForm");
							eSF.studentIDs.value = studentIDs;
							eSF.submit();
						}
					}
				// -->
				</script>
			</cfif>

			<table class="list" width="100%">
				<tr>
					<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
						<th><input name="selectAllCheckbox" id="selectAllCheckbox" type="checkbox" onclick="toggleSelectAll(this.form);"></th>
					</cfif>
					<th><a href="#script_name#?view=#view#&orderBy=Student.Student_ID<cfif orderBy eq 'Student.Student_ID' and orderDir eq 'asc'></th>&orderDir=desc</cfif>">Student ID<cfif orderBy eq "Student.Student_ID">&nbsp;&nbsp;<cfif orderDir eq "asc">#ascImage#<cfelse>#descImage#</cfif></cfif></a>
					<th><a href="#script_name#?view=#view#&orderBy=Site.Site<cfif orderBy eq 'Site.Site' and orderDir eq 'asc'>&orderDir=desc</cfif>">Site<cfif orderBy eq "Site.Site">&nbsp;&nbsp;<cfif orderDir eq "asc">#ascImage#<cfelse>#descImage#</cfif></cfif></a></th>
					<th><a href="#script_name#?view=#view#&orderBy=Student.Origin<cfif orderBy eq 'Student.Origin' and orderDir eq 'asc'>&orderDir=desc</cfif>">Origin<cfif orderBy eq "Student.Origin">&nbsp;&nbsp;<cfif orderDir eq "asc">#ascImage#<cfelse>#descImage#</cfif></cfif></a></th>
					<!--- <th><a href="#script_name#?view=#view#&orderBy=Study_ID<cfif orderBy eq 'Study_ID' and orderDir eq 'asc'>&orderDir=desc</cfif>">Study ID<cfif orderBy eq "Study_ID">&nbsp;&nbsp;<cfif orderDir eq "asc">#ascImage#<cfelse>#descImage#</cfif></cfif></a></th> --->
					<th><a href="#script_name#?view=#view#&orderBy=First_Name<cfif orderBy eq 'First_Name' and orderDir eq 'asc'>&orderDir=desc</cfif>">First Name<cfif orderBy eq "First_Name">&nbsp;&nbsp;<cfif orderDir eq "asc">#ascImage#<cfelse>#descImage#</cfif></cfif></a></th>
					<th><a href="#script_name#?view=#view#&orderBy=Last_Name<cfif orderBy eq 'Last_Name' and orderDir eq 'asc'>&orderDir=desc</cfif>">Last Name<cfif orderBy eq "Last_Name">&nbsp;&nbsp;<cfif orderDir eq "asc">#ascImage#<cfelse>#descImage#</cfif></cfif></a></th>
					<th><a href="#script_name#?view=#view#&orderBy=Student.Address<cfif orderBy eq 'Student.Address' and orderDir eq 'asc'>&orderDir=desc</cfif>">Address<cfif orderBy eq "Student.Address">&nbsp;&nbsp;<cfif orderDir eq "asc">#ascImage#<cfelse>#descImage#</cfif></cfif></a></th>
					<th><a href="#script_name#?view=#view#&orderBy=Student.City<cfif orderBy eq 'Student.City' and orderDir eq 'asc'>&orderDir=desc</cfif>">City<cfif orderBy eq "Student.City">&nbsp;&nbsp;<cfif orderDir eq "asc">#ascImage#<cfelse>#descImage#</cfif></cfif></a></th>
					<th><a href="#script_name#?view=#view#&orderBy=Phone1<cfif orderBy eq 'Phone1' and orderDir eq 'asc'>&orderDir=desc</cfif>">Phone 1<cfif orderBy eq "Phone1">&nbsp;&nbsp;<cfif orderDir eq "asc">#ascImage#<cfelse>#descImage#</cfif></cfif></a></th>
					<th><a href="#script_name#?view=#view#&orderBy=Phone2<cfif orderBy eq 'Phone2' and orderDir eq 'asc'>&orderDir=desc</cfif>">Phone 2<cfif orderBy eq "Phone2">&nbsp;&nbsp;<cfif orderDir eq "asc">#ascImage#<cfelse>#descImage#</cfif></cfif></a></th>
					<th><a href="#script_name#?view=#view#&orderBy=DOB<cfif orderBy eq 'DOB' and orderDir eq 'asc'>&orderDir=desc</cfif>">DOB<cfif orderBy eq "DOB">&nbsp;&nbsp;<cfif orderDir eq "asc">#ascImage#<cfelse>#descImage#</cfif></cfif></a></th>
				</tr>
				<cfloop query="students">
					<tr<cfif currentRow mod 2 eq 0> class="evenRow"<cfelse> class="oddRow"</cfif>>
						<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
							<td><input type="checkbox" name="studentIDs" value="#Student_ID#" onclick="updateSelectAll(this.checked);"<cfif ListFind(studentIDs, Student_ID)> checked</cfif>></td>
						</cfif>
						<td>#Student_ID#</td>
						<td>#Site#</td>
						<td>#Origin#</td>
						<!--- <td>#Study_ID#</td> --->
						<td>#First_Name#</td>
						<td>#Last_Name#</td>
						<td>#Address#</td>
						<td>#City#</td>
						<td>#Phone1#</td>
						<td>#Phone2#</td>
						<td>#DateFormat(DOB, "m/d/yyyy")#</td>
					</tr>
				</cfloop>
			</table>
		</cfif>

	</cfform>

	<cfif students.RecordCount eq 0>

		<div class="alert alert-info notFound">No students with the selected filter criteria</div>

		<!--- show filter --->
		<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
			<script type="text/javascript" language="javascript">
			<!--
				toggleVisibility('filterSelections');
				toggleVisibility('filterButtons');
				updateFilterLink();
			// -->
			</script>
		</cfif>

	</cfif>

</cfoutput> --->